﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using DefectDBTypes;

namespace Defecter.Server
{
	#region Class Session
	/// <summary>
	/// 
	/// </summary>
	/// <remarks>
	/// </remarks>
	public class Session
	{
		#region Session - Types
		#endregion

		#region Session - Fields
		private	User			s_user;
		private Guid			s_id;
		private bool			s_is_logged_on;
		#endregion

		#region Session - Delegates and Events
		#endregion

		#region Session - Properties
		public Guid Id
		{
			get
			{
				return s_id;
			}
		}		/* property Session Id */

		public User User
		{
			get
			{
				return s_user;
			}
		}		/* property Session User */
		#endregion

		#region Session - Constructors
		public Session ()
			: base()
		{
			s_id = Guid.NewGuid();
		}		/* constructor Session */
		#endregion

		#region Session - Methods
		public string LogOn (string userName, string userId)
		{
			// logon
			// return null or error
			return null;
		}		/* method Session LogOn */
		#endregion
	}			/* class Session */
	#endregion

	#region Class SessionCollection
	/// <summary>
	/// 
	/// </summary>
	/// <remarks>
	/// </remarks>
	public class SessionCollection: Dictionary<Guid,Session>
	{
		#region SessionCollection - Types
		#endregion

		#region SessionCollection - Fields
		#endregion

		#region SessionCollection - Delegates and Events
		#endregion

		#region SessionCollection - Properties
		new public Session this[Guid id]
		{
			get
			{
				lock(this)
					return base[id];
			}
		}		/* property SessionCollection Item */
		#endregion

		#region SessionCollection - Constructors
		public SessionCollection ()
			: base()
		{
		}		/* constructor SessionCollection */
		#endregion

		#region SessionCollection - Methods
		public void Add (Session session)
		{
			Add(session.Id, session);
		}		/* method SessionCollection Add */

		new public void Add (Guid sessionId, Session session)
		{
			lock(this)
				base.Add(sessionId,session);
		}		/* method SessionCollection Add */

		new public void Remove (Guid sessionId)
		{
			lock(this)
				base.Remove(sessionId);
		}		/* method SessionCollection Remove */

		public void Remove (Session session)
		{
			this.Remove(session.Id);
		}		/* method SessionCollection Remove */
		#endregion
	}			/* class SessionCollection */
	#endregion
}